// https://leetcode.cn/problems/ur2n8P/
#include <iostream>
#include <vector>
#include <map>
#include <set>


using namespace std;

class Solution {
public:
    bool sequenceReconstruction(vector<int>& nums, vector<vector<int>>& sequences) {
        map<int, int> myMap;
        for (int i = 0; i < nums.size() - 1; i++) {
            myMap[nums[i]] = nums[i + 1];
        }
        for (auto items : sequences) {
            for (int i = 0; i < items.size() - 1; i++) {
                if (myMap.find(items[i]) != myMap.end() && myMap[items[i]] == items[i + 1]) {
                    myMap.erase(items[i]);
                }
            }
        }
        if (myMap.empty()) return true;
        return false;

    }
};

int main(){
    Solution so;
    vector<int> nums = {1,2,3};
    vector<vector<int>> se = { {1,2},{1,3} };
    if (so.sequenceReconstruction(nums, se)) {
        cout << "yes" << endl;
    }

    return 0;
}